package com.todo.event.activity.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/1/7 14:13
 * @description
 */
@Getter
@AllArgsConstructor
public enum EventTypeEnum {
    RABBITMQ(1, "RABBITMQ", "RABBITMQ"),
    ROCKETMQ(2, "ROCKETMQ", "ROCKETMQ"),
    KAFKA(3, "KAFKA", "KAFKA"),

    INTERFACE(20, "INTERFACE", "接口"),


    MYSQL_BIN_LOG(40, "MYSQL_BIN_LOG", "MySQL binlog"),
    ;


    private static Map<Integer, EventTypeEnum> typeMap = Arrays
            .stream(EventTypeEnum.values())
            .collect(Collectors.toMap(EventTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static EventTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
